﻿#include "Render.h"

Render::Render(RENDER_TYPE Type,int Width,int Height,QWidget *parent):QWidget(parent)
{
    m_RenderType = Type;
    x = 0;
    y = 0;
    m_WinWidth = Width;
    m_WinHeight = Height;
    m_VideoWidth = 0;
    m_VideoHeight = 0;
    img_scaler = NULL;
    req_resize = false;
    play_state = 0;

    this->resize(Width,Height);
    this->setMinimumSize(Width, Height);
    memset(&dst_video_frame, 0, sizeof(VideoFrame));
}

void Render::DeInit()
{
    if(dst_video_frame.data[0]) {
        free(dst_video_frame.data[0]);
        dst_video_frame.data[0] = NULL;
    }
    if(img_scaler) {
        delete img_scaler;
        img_scaler = NULL;
    }
}

int Render::GetWidth()
{
    return m_WinWidth;
}

int Render::GetHeight()
{
    return m_WinHeight;
}

void Render::StartPlay()
{
    play_state = 1;
}

void Render::StopPlay()
{
    play_state = 2;
    update();
}

Render::~Render()
{
    DeInit();
}
